﻿/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#include "ProductVersion.h"
#include <QSettings>
#include "Global.h"
namespace  {
    const int MAX_CHIP_NUM = 100;
}
ProductVersionClass::ProductVersion::ProductVersion()
{
    QSettings cfg(Global::GetAppConfigPath() + "\\config_all_chip_type.ini", QSettings::IniFormat);
    uint32_t configIdNum = cfg.value("AHHCHIPTYPECONFIG/CONFIG_ID_NUM").toUInt();
    if (configIdNum > MAX_CHIP_NUM) {
        configIdNum = MAX_CHIP_NUM;
    }
    for (uint32_t i = 1; i <= configIdNum; i++) {
        int id = cfg.value("AHHCHIPTYPECONFIG/CONFIG_ID" + QString::number(i)).toInt();
        if (id == 0) {
            continue;
        }
        unsigned int attributes = cfg.value("AHHCHIPTYPECONFIG/ATTRIBUTES" + QString::number(i)).toUInt();
        mapAttributes[id] = attributes;
    }
}

ProductVersionClass::ProductVersion::~ProductVersion()
{
}

bool ProductVersionClass::ProductVersion::GetIsProductVersion() const
{
    if ((mapAttributes[static_cast<unsigned int>(Global::currentChipTypeId)] & 0x00000001) != 0) {
        return true;
    }
    return false;
}
